package com.pengpeng.advice.service;

import com.pengpeng.advice.entity.User;
import com.pengpeng.advice.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 彭鹏
 * @date 2021/10/30.
 */
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;
    @Override
    @Transactional
    public int insert(String userName) {
        User user = User.builder().id(1).age(18).name(userName).sex("女").password("111").build();
        int num = userMapper.insert(user);

        int aa = num / 0;
        return num;
    }

    @Override
    @Transactional
    public int insert2(String userName) {
        User user = User.builder().id(1).age(28).name(userName).sex("男").password("222").build();
        int num = userMapper.insert(user);

        return num;
    }
}
